<!DOCTYPE html>
<html
  lang="zh"
  xmlns:th="http://www.thymeleaf.org"
  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
>
  <head>
    <th:block th:include="include :: header('主题党日列表')" />
  </head>
  <body class="gray-bg">
    <div class="container-div">
      <div class="row">
        <div class="col-sm-12 search-collapse">
          <form id="formId">
            <div class="select-list">
              <ul>
                <li>
                  <label>活动主题：</label>
                  <input type="text" name="title" />
                </li>
                <li>
                  <label>活动日期：</label>
                  <input
                    type="text"
                    class="form-control"
                    name="activityDate"
                    id="activityDate"
                    placeholder="请选择日期"
                    readonly
                  />
                </li>
                <li>
                  <label>状态：</label>
                  <select name="status">
                    <option value="">所有</option>
                    <option value="0">未开始</option>
                    <option value="1">进行中</option>
                    <option value="2">已结束</option>
                  </select>
                </li>
                <li>
                  <a
                    class="btn btn-primary btn-rounded btn-sm"
                    onclick="$.table.search()"
                    ><i class="fa fa-search"></i>&nbsp;搜索</a
                  >
                  <a
                    class="btn btn-warning btn-rounded btn-sm"
                    onclick="$.form.reset()"
                    ><i class="fa fa-refresh"></i>&nbsp;重置</a
                  >
                </li>
              </ul>
            </div>
          </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
          <a
            class="btn btn-success"
            onclick="$.operate.add()"
            shiro:hasPermission="dj:theme:party:day:add"
          >
            <i class="fa fa-plus"></i> 新增主题党日
          </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
          <table id="bootstrap-table"></table>
        </div>
      </div>
    </div>

    <th:block th:include="include :: footer" />

    <script th:inline="javascript">
      /*<![CDATA[*/
      var editFlag = [[${@permission.hasPermi('dj:theme:party:day:edit')}]];
      var prefix = ctx + "dj/theme/party/day";

      $(function() {
      	var options = {
      		id: "bootstrap-table",
      		url: prefix + "/list",
      		createUrl: prefix + "/add",
      		updateUrl: prefix + "/edit/{id}",
      		removeUrl: prefix + "/remove",
      		exportUrl: prefix + "/export",
      		viewUrl: prefix + "/view/{id}",
      		modalName: "主题党日",
      		columns: [{
      			checkbox: true
      		},
      		{
      			field: 'id',
      			title: '主题党日ID'
      		},
      		{
      			field: 'title',
      			title: '活动主题',
      			align: 'center'
      		},
      		{
      			field: 'activityDate',
      			title: '活动日期',
      			align: 'center'
      		},
      		{
      			field: 'activityTime',
      			title: '活动时间',
      			align: 'center'
      		},
      		{
      			field: 'location',
      			title: '活动地点',
      			align: 'center'
      		},
		{
			field: 'participantNames',
			title: '参与人员',
			align: 'center'
		},
		{
			field: 'organizer',
			title: '组织者',
			align: 'center'
		},
		{
			field: 'status',
      			title: '状态',
      			align: 'center',
      			formatter: function(value, row, index) {
      				if (value == 0) {
      					return '<span class="label label-default">未开始</span>';
      				} else if (value == 1) {
      					return '<span class="label label-primary">进行中</span>';
      				} else if (value == 2) {
      					return '<span class="label label-success">已结束</span>';
      				} else {
      					return value;
      				}
      			}
      		},
      		{
      			field: 'createTime',
      			title: '创建时间',
      			align: 'center'
      		},
      		{
      			title: '操作',
      			align: 'center',
      			formatter: function(value, row, index) {
      				var actions = [];
      				actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.view(\'' + row.id + '\')" shiro:hasPermission="dj:theme:party:day:view"><i class="fa fa-eye"></i> 查看</a> ');
      				actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
      				actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash"></i> 删除</a>');
      				return actions.join('');
      			}
      		}]
      	};
      	$.table.init(options);

      	// 添加全局表格刷新函数，供子窗口调用
      	window.refreshTable = function() {
      		console.log('调用自定义refreshTable函数刷新表格');
      		$("#bootstrap-table").bootstrapTable('refresh');
      	};
      });
      /*]]>*/
    </script>
  </body>
</html>
